<?php

/**
 * Class of Validate Amount template
 *
 * @author BUI TIEN HIEP
 * @email bthiep@lhv.vn
 */
class ValidateAmount extends AbstractValidateFactory {

    /**
     * Validate amount
     * @param type $expenses
     * @return boolean
     */
    public function validate($expenses = array()) {
        $bRet = false;
        $field = $this->policy['rules'][0]['field'];
        $value = $this->policy['rules'][0]['value'];
        foreach ($expenses as $expense) {
            if ($expense[$field] > $value) {
                $bRet = true;
                $this->message = $this->policy['message'];
                break;
            }
        }
        return $bRet;
    }

}
